\documentclass{article}
\usepackage{amssymb}
\begin{document}

\title{\LaTeX\ Primer for Math 31}
\author{Scott LaLonde}
\date{\today}
\maketitle

\section*{Overview}
\LaTeX\ is a typesetting environment. It contains large libraries of mathematical symbols, which allows one to quickly typeset mathematical equations (provided that you
have memorized some of the basic commands). Once you have practiced creating some \LaTeX\ documents, you will find that it is much more efficient for typing 
mathematical formulae than Microsoft Word. (The end result also looks much nicer.)

\section{Getting Started}
At its heard, \LaTeX\ is really a programming language. That is, the user types up ``raw'' \LaTeX\ code and then compiles it into a PDF document. The raw code can
be quite ugly, but the end result is usually quite nice. With this in mind, you will need two pieces of software in order to typeset documents using \LaTeX:
\begin{itemize}
	\item A \LaTeX\ distribution: this contains all the libraries of commands that you will usually need, as well as the software necessary for creating PDF documents from
		your code. Some common distributions are:
		\begin{itemize}
			\item TeX Live (Windows and Linux)
			\item MiKTex (Windows)
			\item MacTeX (Mac)
		\end{itemize}
	
	\item A \LaTeX\ editor: this is a piece of software where you actually write your \LaTeX\ code. It provides a graphical interface for working with \LaTeX\. Some popular 
		ones are:
		\begin{itemize}
			\item TexMaker (Windows, Mac, Linux)
			\item TeXShop (Mac)
			\item TeXnicCenter (Windows)
		\end{itemize}
\end{itemize}

\noindent
Oftentimes you can download \LaTeX\ distributions packaged together with editors. (For example, TeXShop comes with MacTeX.)

\section{Creating Basic Documents}
In order to create simple \LaTeX\ documents, you really only need to start by ``wrapping'' the document in the following series of commands:
\begin{quote}
	\begin{verbatim}
		\documentclass{article}
		\begin{document}
		     .
		     .
		     .		
		\end{document}
	\end{verbatim}
\end{quote}
The main body of your document (i.e., everything that you want printed in your PDF) goes between the \verb;\begin{document}; and \verb;\end{document}; commands. 
The command \verb;\documentclass{article}; tells \LaTeX\ what type of document you would like to produce. For short documents, \verb;article; is the preferred class, but
there are other ones (such as \verb;book; and \verb;report;). The \verb;\documentclass; command also has optional inputs, through which you can control things such as
font size and paper size.

Once you've created the necessary beginning and end for your document, you can begin entering the actual content. Normal text is entered just as you would expect:
\begin{quote}
	\begin{verbatim}
		\documentclass{article}
		\begin{document}
		     The quick brown fox jumps over the lazy dog.	
		\end{document}
	\end{verbatim}
\end{quote}
You would then need to compile the code to create a PDF document. Most editors should have a command for ``Typeset'' or ``Compile'' that will do this. If we do so, the 
example above produces:

\begin{quote}
	The quick brown fox jumps over the lazy dog.
\end{quote}

Of course the creation of simple text documents is not where the real power of \LaTeX\ lies. It is used primarily for typesetting mathematical formulae, so let's do some 
examples here. In general, this will require you to learn (or at least look up) the commands for various mathematical symbols. We'll introduce a few symbols as we go 
along, and there are many good resources for looking up other symbols. Suppose we want to typeset the following sentence:
\begin{quote}
	Let $G$ be a group. We say that $G$ is abelian if $ab = ba$ for all $a, b \in G$.
\end{quote}
Of course we know how to type the words, but how do we make the mathematical symbols appear correctly? This is achieved by wrapping the formulae in dollar signs:
\begin{quote}
	\begin{verbatim}
		Let $G$ be a group. We say that $G$ is abelian if $ab = ba$ 
		for all $a, b \in G$.
	\end{verbatim}
\end{quote}

In the example above, all the mathematical symbols appear ``inline,'' in the sense that they occur on the same line as the words. You have probably seen in math books
that equations are often emphasized by placing them on a separate line. This can be achieved in \LaTeX\ by encasing the formula in delimiters of the form \verb;\[ ... \];.
For example, suppose we wanted to typeset the following:
\begin{quote}
	Let $G$ be a finite cyclic group with generator $a$, and let $n = o(a)$. Then for any integer $m$, we have
	\[
		o(a^m) = \frac{o(a)}{\gcd(m, o(a))}.
	\]
\end{quote}
This is achieved via the following code:
\begin{quote}
	\begin{verbatim}
		Let $G$ be a finite cyclic group with generator $a$, and let 
		$n = o(a)$. Then for any integer $m$, we have
		\[
		     o(a^m) = \frac{o(a)}{\gcd(m, o(a))}.
		\]
	\end{verbatim}
\end{quote}
Note also that here we have invoked three new symbols: \verb;a^m; gives us $a^m$, \verb;gcd; produces $\gcd$, and the command \verb;\frac{a}{b}; produces the 
fraction $\frac{a}{b}$.

\section{Examples}
In general, the best way to learn to use \LaTeX\ (and to memorize some of the common symbols) is to practice with it. Therefore, this section is devoted to simple 
examples and exercises.

\paragraph{Example 1:} Typeset the following block of text:
\begin{quote}
	Let $D_3$ denote the third dihedral group. Then $D_3$ has order $6$.
\end{quote}
[Hint: Use the underscore \verb;_; to produce subscripts.]

\paragraph{Example 2:} Reproduce the following text, complete with offset equations:
\begin{quote}
	Let $G$ be a group. For any $a, b \in G$, we have
	\[
		(ab)^{-1} = b^{-1} a^{-1}.
	\]
	Furthermore,
	\[
		(ab)^{-1} = a^{-1} b^{-1}
	\]
	if and only if $G$ is abelian.
\end{quote}

\paragraph{Example 2:} For this problem, you will need to insert the command \verb;\usepackage{amssymb}; before the \verb;\begin{document}; command. That is,
your document should look like:
\begin{quote}
	\begin{verbatim}
		\documentclass{article}
		\usepackage{amssymb}
		\begin{document}
		     .
		     .
		     .		
		\end{document}
	\end{verbatim}
\end{quote}
Reproduce the following statement of B\'{e}zout's lemma:
\begin{quote}
	Let $m, n \in \mathbb{Z}$, and let $d = \gcd(m, n)$. Then there exist $x, y \in \mathbb{Z}$ such that
	\[
		mx + ny = d.
	\]
\end{quote}
The symbol $\mathbb{Z}$ is produced with the command \verb;\mathbb{Z};. (This is why we needed the package \verb;amssymb;.)
\end{document}